﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace ExtractUrls
{
    class ExtractUrls
    {
        static void Main(string[] args)
        {
            string text = @"http://google.com http://dir.bg http://www.mail.bg www.gbg.bg http://www.tu-sofia.com sportal.bg";
            string pattern = @"(http://)?(www.)?(\w|_|-|\.)*\.[\w]{1,3}";

            Regex regex = new Regex(pattern);
            Match match = regex.Match(text);

            while (match.Success)
            {
                Console.WriteLine(match.Value);
                match = match.NextMatch();
            }
        }
    }
}
